package cn.hzu580.interceptor;

import javax.annotation.Resource;

import org.apache.struts2.ServletActionContext;

import com.opensymphony.xwork2.Action;
import com.opensymphony.xwork2.ActionInvocation;
import com.opensymphony.xwork2.interceptor.MethodFilterInterceptor;

import cn.hzu580.bean.LoginedUserPool;

public class LoginInterceptor extends MethodFilterInterceptor{

	
	@Resource
	private LoginedUserPool loginedUserPool;
	
	@Override
	protected String doIntercept(ActionInvocation actionInvocation) throws Exception {
		if(!loginedUserPool.isLogined()){
			ServletActionContext.getResponse().getWriter().print("failed_access_denied");
			ServletActionContext.getResponse().setStatus(401);
		}else{
			actionInvocation.invoke();
		}
		return Action.NONE;
	}

	public LoginedUserPool getLoginedUserPool() {
		return loginedUserPool;
	}

	public void setLoginedUserPool(LoginedUserPool loginedUserPool) {
		this.loginedUserPool = loginedUserPool;
	}

	
	
}
